package com.tanglongan.designPattern.dp14_command.demo00.better;

import com.tanglongan.designPattern.dp14_command.demo00.better.cuisine.ICuisine;

import java.util.ArrayList;
import java.util.List;

public class XiaoEr {

    private final List<ICuisine> cuisineList = new ArrayList<>();

    public void order(ICuisine cuisine) {
        cuisineList.add(cuisine);
    }

    public synchronized void placeOrder() {
        for (ICuisine cuisine : cuisineList) {
            cuisine.cook();
        }
        cuisineList.clear();
    }

}
